package controllers.api;

import java.util.ArrayList;
import java.util.List;

import models.Group;
import models.User;
import models.WallThread;
import models.myThread;

public class WallPost extends API{
	public static void wallpost(){
		WallThread wallthread=new WallThread();
		//List<String> list=new ArrayList<String>();
		String post=request.params.get("post");
		String id=request.params.get("id");
		String uid=session.get("sessionUser");
		User user=User.find("by_id",id).first();
		User To=User.find("by_id",uid).first();
		//Group group=Group.find("by_id",user.getGroupID()).first();
		/*for(int i=0;i<group.getMembers().size();i++){
			User userpost=User.find("by_id",group.getMembers().get(i)).first();
			wallthread.getToMembers().add(userpost.getId());
		}*/
		wallthread.setFromName(user.getName());
		wallthread.setFromId(user.getId());
		wallthread.setToName(To.getName());
		wallthread.setToId(To.getId());
		wallthread.setPost(post);
		wallthread.save();
		json(wallthread);
	}
	public static void thredlist(){
		List<WallThread> list=WallThread.find().fetch();
		json(list);
	}
}
